//
//  Contact.m
//  OC_05_数组_字典和集合
//
//  Created by wyx on 16/3/1.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "Contact.h"

@implementation Contact
- (instancetype)initWithName:(NSString *)name sex:(NSString *)sex number:(NSInteger)number addres:(NSString *)addres nameOfGroup:(NSString *)nameOfGroup age:(NSInteger)age{
    self = [super init];
    if (self) {
        _name = name;
        _sex = sex;
        _number = number;
        _addres = addres;
        //根据 name,获取其首字母,然后转化为大写最后赋值给_groupName
        _nameOfGroup = [[name substringToIndex:1] uppercaseString];
        _age = age;
    }
    return self;
}
+ (instancetype)contact{
    return [[Contact alloc] init];
}
+ (instancetype)contactWithName:(NSString *)name sex:(NSString *)sex number:(NSInteger)number addres:(NSString *)addres nameOfGroup:(NSString *)nameOfGroup age:(NSInteger)age{
    return [[Contact alloc] initWithName:name sex:sex number:number addres:addres nameOfGroup:nameOfGroup age:age];
}
- (void)showContact:(Contact *)con{
    NSLog(@"name:%@, sex:%@, number:%ld, addres:%@, nameOfGroup:%@, age:%ld",_name,_sex, _number, _addres, _nameOfGroup, _age);
}
- (NSString *) description{
    return [NSString stringWithFormat:@"name: %@ number: %ld",_name, _number];
}
@end
